/**
Copyright 2011 Steven Moxley

This file is part of Joggle.

Joggle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Joggle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Joggle.  If not, see <http://www.gnu.org/licenses/>.
*/
package edu.gwu.cs.joggle;

/**
 * @author      Steven Moxley <steven.moxley@gmail.com>
 * @version     1                
 * @since       2011-12-20
 */
public class Administrator extends User {

	/**
	 * @param fName The Administrator's real first name
	 * @param lName The Administrator's real last name
	 * @param uName The Administrator's Joggle username
	 * @param email The Administrator's preferred email address
	 * Creates a new Administrator
	 */
	public Administrator(String fName, String lName, String uName, String email, String pwd) {
		super(fName, lName, uName, email, pwd);
	}
	
	/**
	 * @param u The Administrator, Auditor, or Player whose password needs to be reset
	 * @return true if all operations succeeded, false otherwise
	 */
	private boolean resetPassword(User u) {
		// prompt u for old password, verify w/ DB lookup (to prevent TOCTOU attack)
		
		// prompt u for password 2 times, verify they match
		
		// hash password (SHA-512? other algorithms?) and save in variable for SQL insert
		String hashedPasswod = "";

		// SQL commands to update u's password field in proper table
		
		if(u instanceof Player) {
			// look in the players table
		} else if(u instanceof Auditor) {
			// look in auditors table
		} else if(u instanceof Administrator) {
			// look in admins table
		}
		
		// write event to log somewhere
		
		// return true if all operations succeeded, notify user of success
		return true;
	}
	
	public String toString() {
		return "The Administrator " + firstName + " " + lastName + " (" + userName + ") can be reached at " + email + ".";
	}
	
}
